<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>审计管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="{{asset('layui/css/layui.css')}}" media="all">
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="{{asset('Jquery/jquery-3.3.1.js')}}"></script>
    <script src="{{asset('layui/layui.js')}}"></script>
    <script src="/comment/comment.js"></script>
</head>

<body>
<style>
    #item th {
        color: black;
        text-align: center;
    }

    #content th {
        color: #16181b;
        text-align: center;
    }
</style>
<div class="layui-form" id="movieList">
    <form action="{{Route('audit.index')}}" method="get" id="data">
        <table class="layui-table">
            <thead>
            <tr>
                <th colspan="9" style="color:#666666;font-size: 18px;text-align: center"> 审计列表</th>
            </tr>
            <tr>

            </tr>
            <tr>
                <th colspan="9">

                    <div class="layui-inline">
                        <select name="is_audit" lay-filter="select" id="zone">
                            <option value="">是否审计</option>
                            <option value="1">已审计</option>
                            <option value="0">未审计</option>
                        </select>
                    </div>

                    <div class="layui-inline">
                        <select name="project_id" lay-filter="select" id="zone">
                            <option value="">请选择项目</option>
                            @foreach($projects as $project)
                                <option value="{{$project->id}}">{{$project->name}}</option>
                            @endforeach
                        </select>
                    </div>
                    {{--<div class="layui-inline">--}}
                    {{--<select name="block_id" lay-filter="select" id="type">--}}
                    {{--<option value="">请选择区块名称</option>--}}
                    {{--@foreach($blocks as $block)--}}
                    {{--<option value="{{$block->id}}">{{$block->block_name}}</option>--}}
                    {{--@endforeach--}}
                    {{--</select>--}}
                    {{--</div>--}}

                    <div class="layui-inline">
                        <select name="levy_house_num" lay-filter="select" id="type">
                            <option value="">请选择房屋编号</option>
                            @foreach($houses as $house)
                                <option value="{{$house->levy_house_num}}">{{$house->levy_house_num}}</option>
                            @endforeach
                        </select>
                    </div>

                    <div class="layui-inline">
                        <input type="text" name="owner" lay-verify="required" placeholder="产权人姓名" autocomplete="off"
                               class="layui-input">
                    </div>


                    <div class="layui-inline">
                        <button class="layui-btn  layui-btn-radius " id="search"><i class="layui-icon layui-icon-search"
                                                                                    style="font-size: 15px; color:black;"></i><b
                                    style="color:white">搜索</b></button>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-primary layui-btn-radius layui-btn-warm" id="reset"><i
                                    class="layui-icon layui-icon-set-fill"
                                    style="font-size: 15px; color:dodgerblue;"></i><b style="color:white">重置</b>
                        </button>
                    </div>
                    <div class="layui-inline">
                        <input type="hidden" name="video_type" value="1">
                    </div>
                </th>
            </tr>
            </thead>
        </table>
    </form>

    <div class="oldData" id="oldData">
        <table class="layui-table">
            <thead>
            <tr id="item">
                <th>
                    <button class="layui-btn layui-btn-xs ">序号</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs ">房屋编号</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs">产权人</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs">联系电话</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs">拆迁款(¥)</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs">补偿金(¥)</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs">劳务费(¥)</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs ">应付补偿金额(¥)</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs ">是否同意</button>
                </th>
                <th>
                    <button class="layui-btn layui-btn-xs ">操作</button>
                </th>
            </tr>
            </thead>
            <tbody>
            @foreach($audits as $k=>$audit)
                @if($audit->houses)
                    <tr id="content" data-id="{{$audit->id}}">
                        <th>
                            <button class="layui-btn layui-btn-xs layui-bg-cyan">{{$k+1}}</button>
                        </th>

                        <th>{{$audit->houses->levy_house_num}}</th>
                        <th>{{$audit->houses->owner}}</th>
                        <th>{{$audit->houses->phone}}</th>
                        <th>{{$audit->houses->remove_money}}</th>
                        <th>{{$audit->houses->compensation_money}}</th>
                        <th>{{$audit->houses->service_fee}}</th>
                        <th>{{$audit->houses->pay_money}}</th>
                        <th>
                            <span class="layui-btn layui-btn-sm layui-btn-radius show_img">查看合同图片</span>
                        </th>

                        @if($audit->is_audit == 1)
                            <th>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <input type="checkbox" name="is_sign" lay-skin="switch" lay-text="是" checked
                                               disabled>
                                    </div>
                                </div>
                            </th>
                        @else
                            <th class="change_on">
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <input type="checkbox" name="is_sign" lay-skin="switch" lay-text="ON|OFF">
                                    </div>
                                </div>
                            </th>
                        @endif



                    </tr>
                @endif
            @endforeach

            <tr>
                <th colspan="10" style="text-align: center;color: darkorange">{{$audits->links()}}</th>
            </tr>
            </tbody>
        </table>

    </div>
</div>
</body>


<script>
    layui.use('form', function () {
        var form = layui.form;
    });

    // 是否审计
    $('.change_on').click(function () {
        var id = $(this).parents('tr').data('id');

        $.ajax({
            type: 'PATCH',
            url: '/audit/change_on',
            data: {id: id,},
            success: function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, {
                        icon: 5,
                        time: 1200 //2秒关闭（如果不配置，默认是3秒）
                    });
                    return false;
                } else {
                    layer.msg(data.msg, {
                        icon: 6,
                        time: 400 //2秒关闭（如果不配置，默认是3秒）

                    }, function () {
                        window.location.reload();
                    });
                }

            }
        })
    });

    // 查看合同图片
    $(".show_img").click(function () {
        var id = $(this).parents('tr').data('id');

        $.post('/audit/show_img', {id:id},function(json) {
            console.log(json);
            layui.use('layer', function () {
                layer.photos({
                    photos: json

                    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                });
            });




        });
    });



</script>


</html>